package com.jeebey.mybatis.dialect.impl;

import com.jeebey.mybatis.dialect.IDialect;

/**
 * @since 1.0
 * @author <a href="mailto:84961426@qq.com">JuST4iT</a>
 * @version $Id: Db2Dialect.java Feb 18, 2016 6:04:28 PM $
 */

public class DB2Dialect implements IDialect {

	public String createPagingSql(String sql, int offset, int size) {
		String _sql_format = "select * from (select _tbl_.*,rownumber() over() as row_num from (%s) as _tbl_) where row_num between %d and %d";
		return String.format(_sql_format, sql, offset + 1, offset + size + 1);
	}

	public String createIdentitySql() {
		return "VALUES IDENTITY_VAL_LOCAL()";
	}

	@Override
	public String createClearCacheSql() {
		return "SELECT 1";
	}
}
